package com.huanong.it.xwweibo.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huanong.it.xwcommon.entity.User;
import com.huanong.it.xwcommon.entity.Weibo;
import com.huanong.it.xwcommon.service.UserService;
import com.huanong.it.xwcommon.service.WeiboService;
import com.huanong.it.xwcommon.vo.Result;
import io.seata.core.context.RootContext;
import io.seata.core.exception.TransactionException;
import io.seata.spring.annotation.GlobalTransactional;
import io.seata.tm.api.GlobalTransactionContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;

@RestController
@RefreshScope
public class WeiboApi {
    @Autowired
    @Qualifier("myWeiboServiceImpl")
    private WeiboService weiboService;
    @Autowired
    private UserService userService;//远程代理

    @Value("${my.upload_dir}")
    private String uploadDir;


    @GetMapping("/weibo")
    public Result<Page<Weibo>> showList(@RequestParam int cur, @RequestParam int size){
        return weiboService.showList(cur, size);
    }

    @GetMapping("/weibo/userLoginname")
    public Result<Page<Weibo>> showListByUser(@RequestParam String userLoginname, @RequestParam int cur, @RequestParam int size){
        return weiboService.showListByUser(userLoginname, cur, size);
    }

}
